import time

from selenium import webdriver

from ..common.ui.Selector import Selector
from .Button import Button
from .Currencybox import Currencybox

import pytest

def test_click_setValue():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/currencybox/index.html")
    time.sleep(2)
    try:
        Button(browser, 'js-value', Selector.CLASS_NAME).click()
        time.sleep(2)
        currencybox = Currencybox(browser, 'coin', Selector.ID)
        assert '100.12' == currencybox.getValue()
    finally:
        browser.close()

def test_setValue():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/currencybox/index.html")
    time.sleep(2);
    try:
        currencybox = Currencybox(browser, 'coin', Selector.ID)
        currencybox.setValue('123.12')
        assert '123.12' == currencybox.getValue()
    finally:
        browser.close();

if __name__ == '__main__':
    pytest.main(['-s','Currencybox_test.py']);